package cn.bluethink.eguan.core.service;

import java.util.HashMap;
import java.util.Map;

import org.springframework.stereotype.Service;

import cn.bluethink.eguan.model.core.EgObject;
import cn.bluethink.eguan.model.core.EgRole;

@Service
public class EgUserPurviewService {
static private Map<Integer,AEgUserPurviewService> userPurviewServices = new HashMap<>();
	
	synchronized static public void addUserPurviewService(Integer otype, AEgUserPurviewService userPurviewService ) {
		userPurviewServices.put(otype, userPurviewService);
	}
	
	/**
	 * 根据用户所在位置，获取其详细权限信息
	 * @param pos 用户所在位置
	 * @param uid 用户ID
	 * @param urole 该用户在江湖中的权限
	 * @return
	 * @throws Exception
	 */
	public EgRole role(EgObject pos, Long uid, EgRole urole ) throws Exception {
		Integer otype = pos.getType().getOtid();
		AEgUserPurviewService userPurviewService =  userPurviewServices.get(otype);
		if ( userPurviewService == null ) return null;
		else return userPurviewService.role(pos,uid,urole);
	}
}
